<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>
   {if  $Request.action =='buyer'}
         {if  $Request.param.status ==''}所有订单{elseif $Request.param.status ==2}卖家确认{elseif $Request.param.status ==3}等待付款{elseif $Request.param.status ==4}卖家发货{elseif $Request.param.status ==5}等待确认{elseif $Request.param.status ==6}交易成功{elseif $Request.param.status ==7}订单关闭{/if}
    {elseif $Request.action == 'seller'}
           {if  $Request.param.status ==''}所有订单{elseif $Request.param.status ==2}等待确认{elseif $Request.param.status ==3}买家付款{elseif $Request.param.status ==4}等待发货{elseif $Request.param.status ==5}买家确认{elseif $Request.param.status ==6}交易成功{elseif $Request.param.status ==7}订单关闭{/if}
  {/if}
  {if  $Request.action =='buyer'}我是买家{elseif $Request.action == 'seller'}我是卖家{/if} - 交易管理</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="keywords" content="">
  <meta name="description" content="">
  {include file="public/css"}
</head>
<body>

<!-- 头部开始 -->
{include file="public/header"}
<!-- 头部结束 -->

<div class="layui-main fly-marginTop fly-user-main ">

<div class="user-left-menu" style="">
<!-- 会员中心导航菜单 -->
{include file="public/left_menu"}
</div>
        <div class="fly-panel fly-panel-user user-right-content" pad20>

        <div class="layui-tab layui-tab-brief" lay-filter="user">

          {if  $Request.action =='buyer'}
             {include file="public/buyer_step"}
          {elseif $Request.action == 'seller'}
               {include file="public/seller_step"}
          {/if}

            {if $Request.param.status ==''}
            <div class="layui-tab-content" style="padding: 20px 0;">
            
            <!-- 筛选 -->
            <form class="layui-form" action="{:url('@user/guarantee/buyer')}" method="post">
               <div class="layui-form-item">
                   <label class="layui-form-label" style="width:60px;">交易标题</label>
                  <div class="layui-input-inline" style="width:250px;">
                    <input type="text" name="keywords" placeholder="请输入交易标题" autocomplete="off" class="layui-input"  value="{$Request.param.keywords}">
                  </div>
                  
   

                    <div class="layui-input-inline" style="width:100px;">
                      <button class="layui-btn layui-btn-normal" lay-submit lay-filter="form">搜 索</button>
                
                    </div>
              </div>
              </form>
           </div>
            {/if}
        <!-- 列表数据开始 -->
          <div class="layui-row">            
              <table class="layui-table " lay-even lay-skin="line" >
                      <colgroup>
                        <col width="300">
                        <col width="100">
                        <col width="200">
                        <col width="100">
                        <col width="200">
                       
                      </colgroup>
                      <thead>
                        <tr>
                          <th>交易详情</th>
                          <th>交易价格</th>
                          <th>交易双方</th>
                          <th>交易状态</th>
                          <th>交易操作</th>
                        </tr> 
                      </thead>
  
                    </table>  
                   {volist name="list" id="vo"}                        
                <table class="layui-table " lay-even lay-skin="line" >
                       <colgroup>
                        <col width="300">
                        <col width="100">
                        <col width="200">
                        <col width="120">
                        <col width="200">
                        
                      </colgroup>
                   <thead>
                        <tr>
                          <th colspan="5">
                          【{if $Think.session.username == $vo.buyer}我是买家{else}我是卖家{/if}】
                          订单号：{$vo.id}  <span style="float:right">{$vo.create_time|date="Y-m-d"}</span></th>
                  
                        </tr> 
                      </thead>
                      <tbody>
                        <tr>
                          <td><a href="{:url('trade/order',['id'=>$vo.id])}">{$vo.title}</a>
                         </td>
                          <td><p class="orange">￥{$vo.price}  </p>
                       
                         </td>
                          <td>卖家： {$vo.seller}
                           <p style="font-size:12px;color:#8d8d8d"> (手续费：{if $vo.fee_type ==1}买家全付{elseif $vo.fee_type ==2}卖家全付{elseif $vo.fee_type ==3}双方各付一半{/if})</p>
                          </td>
<!-- 交易状态 -->
 {if $vo.order_status == 0 && $vo.pay_status== 0  && $vo.shipping_status== 0}
                <!-- 等待卖家确认 -->
               {if  $vo.seller == $Think.session.username}
                  <td>待确认</td>
                   <td>
                    <p><a href="javascript:;" class="layui-btn layui-btn layui-btn-normal layui-btn-sm accept" data-url=" {:url('guarantee/updateOrderStatus',['id'=>$vo.id,'status'=>1])}">接受订单</a>
                    <a href="javascript:;" class="layui-btn layui-btn-primary layui-btn-sm refuse"  data-url=" {:url('guarantee/updateOrderStatus',['id'=>$vo.id,'status'=>-1])}">拒绝订单</a>
                    </p>
                    <p ><a href="{:url('trade/order',['id'=>$vo.id])}">查看详情</a></p>
                   </td>
               {elseif $vo.buyer == $Think.session.username}
                    <td>卖家确认</td>
                     <td><a href="{:url('trade/order',['id'=>$vo.id])}">查看详情</a></td>
               {/if}


          {elseif $vo.order_status == 1 && $vo.pay_status== 0  && $vo.shipping_status== 0}
          <!-- 等待买家付款 -->
             {if  $vo.seller == $Think.session.username}
               <td>待支付</td>
              <td><a href="{:url('trade/order',['id'=>$vo.id])}">查看详情</a></td>
              {elseif $vo.buyer == $Think.session.username}
               <td>未支付</td>
               <td><a href="{:url('trade/order',['id'=>$vo.id])}" class="layui-btn layui-btn-danger layui-btn-sm">立即支付</a>
                <a href="" class="layui-btn layui-btn-primary layui-btn-sm refuse" data-url=" {:url('guarantee/updateOrderStatus',['id'=>$vo.id,'status'=>-1])}">取消</a></td>
               {/if}

          {elseif $vo.order_status == 1 && $vo.pay_status== 1  && $vo.shipping_status== 0}
          <!-- 等待卖家发货 -->
             {if  $vo.seller == $Think.session.username}
               <td>未发货</td>
               <td><a href="{:url('trade/order',['id'=>$vo.id])}" class="layui-btn layui-btn-danger layui-btn-sm">立即发货</a></td>
             {elseif $vo.buyer == $Think.session.username}
              <td>待发货</td>
              <td><a href="{:url('trade/order',['id'=>$vo.id])}">查看详情</a></td>
             {/if}

          {elseif $vo.order_status == 1 && $vo.pay_status== 1  && $vo.shipping_status== 1}
          <!-- 等待买家确认 -->
              {if  $vo.seller == $Think.session.username}
               <td>待确认</td>
               <td><a href="{:url('trade/order',['id'=>$vo.id])}">查看详情</a></td>
             {elseif $vo.buyer == $Think.session.username}
              <td>未确认</td>
              <td><a href="{:url('trade/order',['id'=>$vo.id])}" class="layui-btn layui-btn-danger layui-btn-sm">立即确认</a></td>
             {/if}   

          {elseif $vo.order_status == 1 && $vo.pay_status== 1  && $vo.shipping_status== 2}
            <!--  买家已确认，交易成功 -->
                {if  $vo.seller == $Think.session.username}
                     <td>交易成功</td>
                     <td>{if $vo.seller_evaluate > 0 && $vo.buyer_evaluate > 0}
                           双方已评价
                         {elseif $vo.seller_evaluate >0}
                           我已评价
                         {else}
                           <a href="{:url('trade/order',['id'=>$vo.id])}" >评价</a>
                        {/if}
                     </td>
                   {elseif $vo.buyer == $Think.session.username}
                    <td>交易成功</td>
                    <td>
                     {if $vo.seller_evaluate > 0 && $vo.buyer_evaluate > 0}
                           双方已评价
                         {elseif $vo.buyer_evaluate >0}
                           我已评价
                         {else}
                           <a href="{:url('trade/order',['id'=>$vo.id])}" >评价</a>
                        {/if}
                    </td>
                   {/if}  
           {elseif $vo.order_status == 2 && $vo.pay_status== 0  && $vo.shipping_status== 0}

             <!-- 订单关闭 -->
                {if  $vo.seller == $Think.session.username}
                   <td>订单已关闭</td>
                   <td></td>
                 {elseif $vo.buyer == $Think.session.username}
                  <td>订单已关闭</td>
                  <td></td>
                 {/if}
          {/if}  
<!-- {/if} -->

    
                        </tr>
                     
                      </tbody>
                    </table> 
                   {/volist}
                      <div id="pages">{$page|raw}</div>
                </div>          
       

           </div>
           </div>
        </div>
        </div>
    
</div>
{include file="public/js"}
<!-- 会员底部文件 -->
{include file="public/footer"}



<script>

layui.use(['form','table','laypage','laydate'], function(){
  var form = layui.form;
  var laypage = layui.laypage; 
  var laydate = layui.laydate;
  var table = layui.table;

//监听提交
  form.on('submit(form)', function(data){
     var where = data.field;
     ajax_table(where);
    return false;
  });


// 卖家确认 接受
  $(".accept").on("click",function(){
   
    var url = $(this).attr('data-url');
    $.get(url,function(json){ 
       if(json.code == 0){
          layer.msg(json.msg);
          location.reload();
       }else{
          layer.msg(json.msg);
       }
    });
  });
// 卖家确认 拒绝
  $(".refuse").on("click",function(){
     var url = $(this).attr('data-url');
    $.get(url,function(json){
       if(json.code == 0){
          layer.msg(json.msg);
           location.reload();
       }else{
        layer.msg(json.msg);
       }
    });
  });


});
</script>


</body>
</html>